/* 条件语句-switch 语句
 *
 * @link: https://www.runoob.com/go/go-switch-statement.html
 */

// 包申明
package main

// 引入包
import (
	"fmt"
)

// 入口函数
func main() {
	// 定义局部变量
	var grade string = "B"
	var marks int = 90

	switch marks {
	case 90:
		grade = "A"
	case 80:
		grade = "B"
	case 50, 60, 70:
		grade = "C"
	default:
		grade = "D"
	}

	// 如果含有 = 这种,可以不写 判断的变量
	switch {
	case grade == "A":
		fmt.Printf("优秀!\n")
	case grade == "B", grade == "C":
		fmt.Printf("良好\n")
	case grade == "D":
		fmt.Printf("及格\n")
	case grade == "F":
		fmt.Printf("不及格\n")
	default:
		fmt.Printf("差\n")
	}

	fmt.Printf("你的等级是 %s\n", grade)
}

/*
运行结果:
优秀!
你的等级是 A
*/
